package FD.Gestores;

import FD.Beans.Cliente;

/**
 *
 * @author Administrador
 */
public class GestorClientes {

    public boolean crearCliente(Cliente cS) {

        String sql = "INSERT INTO fastdbd.fd_clientes "
                + "(cliente, nombre, RUC, interface, estado) "
                + "VALUES (" + cS.getIdCliente() + ", '" + cS.getNombre()+ "', '" + cS.getRUC()+ "', '" + cS.getInterfaces()+ "', " + cS.isEstado() + ")";


        return GestorDB.excuteCommand(sql);

    }

    public boolean actualizarCliente(Cliente cS) {

        String sql = "UPDATE fastdbd.fd_Clientes "
                + "SET ";


        if (!cS.getNombre().equals("")) {
            sql = sql + "nombre = '" + cS.getNombre() + "',";
        }

        if (!cS.getRUC().equals("")) {
            sql = sql + "RUC = '" + cS.getRUC() + "',";
        }

        if (!cS.getInterfaces().equals("")) {
            sql = sql + "interface = '" + cS.getRUC() + "',";
        }
/*
        if (sql.endsWith(",")) {
            sql = sql + ",!";
            sql = sql.replace(",!", " ");

        }*/

        sql = sql + " estado = " + cS.isEstado() + "  WHERE Cliente = '" + cS.getIdCliente() + "'";

        return GestorDB.excuteCommand(sql);

    }

    public boolean activaDesactivaCliente(Cliente cS) {
        Cliente u = new Cliente();

        String sql = "UPDATE fastdbd.fd_Clientes "
                + "SET estado = " + cS.isEstado()
                + "WHERE Cliente = '" + cS.getIdCliente() + "'";

        return GestorDB.excuteCommand(sql);

    }
}
